package com.cjy.rules.hammurabi

import com.cjy.rules.hammurabi.entity.User
import com.cjy.rules.hammurabi.rules.TagRules
import hammurabi.{RuleEngine, WorkingMemory}

/**
 *
 * @author cjy
 * @create 2020-03-30
 */
object UserTags {
  def main(args: Array[String]): Unit = {
    val ruleEngine = RuleEngine(new TagRules().rules)
    val tom = new User("user_tom", Array("研究员", "宝宝"))
    val joe = new User("user_joe", Array("大学", "书包"))
    val fred = new User("user_fred", Array("育儿", "汽车"))
    val bob = new User("user_bob", Array("老大", "四级"))

    val workingMemory = WorkingMemory(Set(tom, joe, fred, bob))
    println("使用规则前的数据")
    Set(tom, joe, fred, bob).foreach(println(_))

    ruleEngine execOn workingMemory

    println("使用规则后的数据")
    Set(tom, joe, fred, bob).foreach(println)
  }

}
